var ClientHandler = {
};

ClientHandler.handlers = {};

ClientHandler.add = function(event, fn) {
    if (!fn) {
        cc.log("no fn!");
        return;
    }

    if (this.handlers[event]) {
        cc.log("event:" + event + "' handler has been registered.");
        return;
    }

    this.handlers[event] = fn;
}

ClientHandler.del = function(event) {
    if (!this.handlers[event]) {
        cc.log("event:" + event + "' handler hasn't registered.");
        return;
    }
    delete(this.handlers[event]);
}

ClientHandler.clear = function() {
    this.handlers = {};
}

ClientHandler.post = function(event, data) {
    if (!this.handlers[event]) {
        cc.log("event:" + event + "' handler hasn't registered.");
        return;
    }
    this.handlers[event](data);
}
